<?php
require('db.php');
    class DebugFastInstalator extends FastDatabase{
        function DebugFastInstalator(){
            $ans = self::connect_to_the_db();
    
        //  Array Of SQL queries we need to perform to install the DebugFast
	    $sql_array=array(
"DROP TABLE IF EXISTS `log_deb_calls`;",
"CREATE TABLE IF NOT EXISTS `log_deb_calls` ( `id` double NOT NULL AUTO_INCREMENT, `time_` datetime DEFAULT NULL, `caller` varchar(765) DEFAULT NULL, `small_descr` varchar(765) DEFAULT NULL, `big_descr` blob, PRIMARY KEY (`id`)) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=394 ; ",
"DROP TABLE IF EXISTS `log_deb_items`;",
"CREATE TABLE IF NOT EXISTS `log_deb_items` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `pid` bigint(20) DEFAULT NULL COMMENT 'pid of lod_deb_calls', `time_` datetime DEFAULT NULL, `caller` varchar(255) DEFAULT NULL, `type` varchar(255) DEFAULT NULL COMMENT 'it can be array, or sql, or trace', `data` blob, `small_descr` varchar(255) DEFAULT NULL, `big_descr` text, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4823 ; ",
"DROP TABLE IF EXISTS `log_deb_system`;",
"CREATE TABLE IF NOT EXISTS `log_deb_system` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `data` blob, `descr` varchar(255) DEFAULT NULL COMMENT 'Here I store description', PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;",
	);
	    // Install flag
	    $do_install=true;
        
	    // Performing every Sql query
	    foreach($sql_array as $sql){
		$ans= mysql_query($sql, self::$db_res);
		if(false!=$ans){
			echo "OK <br>";
		}
		else{
			echo "Error <br>";
			$do_install=false;
		}
		
	    }

	    // Check do all tables was instaled
	    if($do_install){
		    echo "DebugFast was successfully installed<br>";
	    }else{
		    echo "Some ERRORS happed during the installation, call Dima.<br>";
	    }
        
        }
    }
    
    $Install = new DebugFastInstalator();
    
?>
